package cn.com.generaldata.os.service.indicator_evaluation.national_economy_contribution;

import org.apache.commons.lang3.Validate;

import cn.com.generaldata.jsme_indicator_system.entity.IndicatorEvaluation;
import cn.com.generaldata.os.service.indicator_constant.ProvinceIndicatorConstant;
import cn.com.generaldata.os.service.indicator_evaluation.IndicatorEvaluationCalculateService;
import cn.com.generaldata.os.vo.IndicatorAccountVO;

/**
 * 海洋生产总值比重评估指标计算类.
 */
public class GOPProportionCalculateService extends IndicatorEvaluationCalculateService {

	private String GOPIndicatorName = ProvinceIndicatorConstant.GOP_INDICATOR_NAME;
	private String GDPIndicatorName = ProvinceIndicatorConstant.GDP_INDICATOR_NAME;

	@Override
	protected Double calculate(IndicatorEvaluation indicator, IndicatorAccountVO indicatorAccountVO) {
		Double GOP = getGOP(indicatorAccountVO, indicatorAccountVO.getYear());
		Double GDP = getGDP(indicatorAccountVO, indicatorAccountVO.getYear());

		return (GOP / GDP) * 100;
	}

	private Double getGDP(IndicatorAccountVO indicatorAccountVO, int year) {

		Double result = getInputOrAccountingIndicatorValue(indicatorAccountVO, year, GDPIndicatorName);
		Validate.isTrue(result != null);
		return result;
	}

	private Double getGOP(IndicatorAccountVO indicatorAccountVO, int year) {
		Double result = getInputOrAccountingIndicatorValue(indicatorAccountVO, year, GOPIndicatorName);
		Validate.isTrue(result != null);
		return result;

	}

}
